package com.bt.lms.ui.page.teaching.arrange;

import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.control.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;

/**
 * 选修课程界面
 */
public class PageNoMustCourse extends VBox {

    /**
     * 选修课程界面宽度
     */
    private double preWidth = 1280;
    /**
     * 选修课程界面高
     */
    private double preHeight = 800;



    public PageNoMustCourse(){

        this.setPadding(new Insets(5));
        this.setSpacing(20);
        this.setPrefSize(preWidth,preHeight);

        //顶部盒子
        HBox topHBox = new HBox();
        initTopHBox(topHBox);
        //新增教学安排盒子
        HBox addTeacherArrangeHBox = new HBox();
        initAddTeacherArrangeHBox(addTeacherArrangeHBox);
        //网格盒子
        VBox tableHBox = new VBox();
        initTableHBox(tableHBox);
        //底部盒子
        HBox bottomHBox = new HBox();
        initBottomHBox(bottomHBox);



        //滚动条盒子
        VBox scrollPaneVBox  = new VBox();
        ScrollPane scrollPane = new ScrollPane();
        scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
        scrollPane.setContent(scrollPaneVBox);
        scrollPane.setPrefSize(preWidth,preHeight);

        scrollPaneVBox.getChildren().addAll(topHBox,addTeacherArrangeHBox,tableHBox,bottomHBox);


        ObservableList<Node> children = this.getChildren();
        children.addAll(scrollPane);

    }

    /**
     * 底部盒子
     * @param bottomHBox
     */
    private void initBottomHBox(HBox bottomHBox) {
        bottomHBox.setPadding(new Insets(10));
        bottomHBox.setSpacing(20);
        bottomHBox.setAlignment(Pos.CENTER);

        //保存按钮
        Button saveBtn = new Button("保存");
        BtnStyle.saveBtn(saveBtn);
        //保存并发布按钮
        Button issueBtn = new Button("保存并发布");
        BtnStyle.saveBtn(issueBtn);
        //取消按钮
        Button cancelBtn = new Button("取消");
        BtnStyle.cancelBtn(cancelBtn);
    }

    /**
     * 网格盒子
     * @param tableHBox
     */
    private void initTableHBox(VBox tableHBox) {
        tableHBox.setSpacing(20);
        tableHBox.setPadding(new Insets(2,2,2,20));
        //网格
        GridPane gridPane = new GridPane();
        gridPane.setHgap(15);
        gridPane.setVgap(20);

        //课程属性标签
        Label coursePropLab = new Label("课程属性");
        coursePropLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //课程属性单选框
        RadioButton requiredRB = new RadioButton("必修");
        RadioButton choiceRB = new RadioButton("选修");

        gridPane.add(coursePropLab,0,1);
        gridPane.add(requiredRB,1,1);
        gridPane.add(choiceRB,2,1);

        //设置课程部分
        //标签
        Label setCourseLab = new Label("设置课程*");
        setCourseLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //文本框
        TextField setCourseTF = new TextField();
        setCourseTF.setId("setCourseTF");
        //选择按钮
        Button selectCourseBtn = new Button("选择");
        BtnStyle.cancelBtn(selectCourseBtn);
        selectCourseBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                selectCourseBtn.setCursor(Cursor.HAND);
            }
        });
        gridPane.add(setCourseLab,0,2);
        gridPane.add(setCourseTF,1,2);
        gridPane.add(selectCourseBtn,2,2);

        //设置教师部分
        //标签
        Label setTeacherLab = new Label("设置教师*");
        setTeacherLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //文本框
        TextField setTeacherTF = new TextField();
        setTeacherTF.setPromptText("可多选");
        setTeacherTF.setId("setTeacherTF");
        //选择按钮
        Button selectTeacherBtn = new Button("选择");
        BtnStyle.cancelBtn(selectTeacherBtn);
        selectTeacherBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                selectTeacherBtn.setCursor(Cursor.HAND);
            }
        });
        gridPane.add(setTeacherLab,0,3);
        gridPane.add(setTeacherTF,1,3);
        gridPane.add(selectTeacherBtn,2,3);

        //设置学员部分
        //设置学员标签
        Label setStuLab = new Label("设置学员*");
        setStuLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //详细文本域
        TextArea detailTA = new TextArea("招生计划A：A班（15/30）；培训项目A：B班（30/30）");
        //选择按钮
        Button selectClassBtn = new Button("选择");
        selectClassBtn.setOnMouseEntered(new EventHandler<MouseEvent>() {
            @Override
            public void handle(MouseEvent event) {
                selectClassBtn.setCursor(Cursor.HAND);
            }
        });

        gridPane.add(setStuLab,0,4);
        gridPane.add(detailTA,1,4);
        gridPane.add(selectClassBtn,2,4);

        //课程性质部分
        //标签
        Label courseCharacterLab = new Label("课程性质*");
        courseCharacterLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //下拉框
        ComboBox courseCharacterCB = new ComboBox<>();
        courseCharacterCB.getItems().add("公共基础课");
        courseCharacterCB.getItems().add("专业基础课");
        courseCharacterCB.getItems().add("学位专业课");
        courseCharacterCB.getItems().add("教育实践");
        courseCharacterCB.getItems().add("其他");
        courseCharacterCB.getSelectionModel().selectFirst();
        gridPane.add(courseCharacterLab,0,5);
        gridPane.add(courseCharacterCB,1,5);

        //学分部分
        //标签
        Label creditLab = new Label("学分*");
        creditLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //文本框
        TextField creditTF = new TextField();
        creditTF.setId("creditTF");
        gridPane.add(creditLab,0,6);
        gridPane.add(creditTF,1,6);

        //总学时部分
        //标签
        Label totalPeriodLab = new Label("总学时*");
        totalPeriodLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //文本框
        TextField totalPeriodTF = new TextField();
        totalPeriodTF.setId("totalPeriodTF");
        gridPane.add(totalPeriodLab,0,7);
        gridPane.add(totalPeriodTF,1,7);

        //单价部分
        //标签
        Label unitPriceLab = new Label("单价*");
        unitPriceLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //文本框
        TextField unitPriceTF = new TextField();
        unitPriceTF.setId("unitPriceTF");
        //下拉框
        ComboBox unitPriceCB = new ComboBox<>();
        unitPriceCB.getItems().add("元/学分");
        unitPriceCB.getItems().add("元/学时");
        unitPriceCB.getSelectionModel().selectFirst();
        gridPane.add(unitPriceLab,0,8);
        gridPane.add(unitPriceTF,1,8);
        gridPane.add(unitPriceCB,2,8);

        //教学方式部分
        //标签
        Label teachingWayLab = new Label("教学方式");
        teachingWayLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //下拉框
        ComboBox teachingWayCB = new ComboBox<>();
        teachingWayCB.getItems().add("在线学习");
        teachingWayCB.getItems().add("面授学习");
        teachingWayCB.getItems().add("混合式学习");
        teachingWayCB.getSelectionModel().selectFirst();
        gridPane.add(teachingWayLab,0,9);
        gridPane.add(teachingWayCB,1,9);

        //选课有效期部分
        //标签
        Label selectCourseStartLab = new Label("选课有效期*");
        selectCourseStartLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //选课开始时间日期选择器
        DatePicker selectCourseStartDP = new DatePicker();
        //至标签
        Label toLab = new Label("至");
        //选课结束时间日期选择器
        DatePicker selectCourseEndDP = new DatePicker();

        gridPane.add(selectCourseStartLab,0,10);
        gridPane.add(selectCourseStartDP,1,10);
        gridPane.add(toLab,2,10);
        gridPane.add(selectCourseEndDP,3,10);

        //预计开课时间部分
        //标签
        Label startLab = new Label("预计开课时间");
        startLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //日期选择器
        DatePicker startDP = new DatePicker();
        gridPane.add(startLab,0,11);
        gridPane.add(startDP,1,11);

        //预计结课时间部分
        //标签
        Label endLab = new Label("预计结课时间");
        endLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //日期选择器
        DatePicker endDP = new DatePicker();
        gridPane.add(endLab,0,12);
        gridPane.add(endDP,1,12);

        //考核形式部分
        //标签
        Label assessLab = new Label("考核形式*");
        assessLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //下拉框
        ComboBox assessCB = new ComboBox<>();
        assessCB.getItems().add("笔试");
        assessCB.getItems().add("口试");
        assessCB.getItems().add("面试");
        assessCB.getItems().add("操作");
        assessCB.getItems().add("机考");
        assessCB.getItems().add("大作业");
        assessCB.getItems().add("实习报告");
        assessCB.getItems().add("其他");
        assessCB.getSelectionModel().selectFirst();
        gridPane.add(assessLab,0,13);
        gridPane.add(assessCB,1,13);

        //平时成绩权重部分
        //标签
        Label usualScoreLab = new Label("平时成绩权重*");
        usualScoreLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //文本框
        TextField usualScoreTF = new TextField();
        usualScoreTF.setId("usualScoreTF");
        usualScoreTF.setPromptText("请输入0-100之间的整数/%");
        gridPane.add(usualScoreLab,0,14);
        gridPane.add(usualScoreTF,1,14);

        //其中部分
        //标签
        Label otherLab = new Label("其中");
        otherLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //学习登录
        //标签
        Label learningLoginLab = new Label("学习登录*");
        //文本框
        TextField learningLoginTF = new TextField();
        learningLoginTF.setId("learningLoginTF");
        learningLoginTF.setPromptText("%");
        //成绩统计规则说明标签
        Label scoreRuleLab = new Label(">>成绩统计规则说明");
        scoreRuleLab.setTextFill(Color.rgb(101,228,255));
        gridPane.add(otherLab,0,15);
        gridPane.add(learningLoginLab,1,15);
        gridPane.add(learningLoginTF,2,15);
        gridPane.add(scoreRuleLab,3,15);

        //课件学习
        //标签
        Label coursewareLearningLab = new Label("课件学习*");
        //文本框
        TextField coursewareLearningTF = new TextField();
        coursewareLearningTF.setPromptText("%");
        coursewareLearningTF.setId("coursewareLearningTF");

        gridPane.add(coursewareLearningLab,1,16);
        gridPane.add(coursewareLearningTF,2,16);

        //论坛交流
        //标签
        Label forumTalkLab = new Label("论坛交流*");
        //文本框
        TextField forumTalkLabTF = new TextField();
        forumTalkLabTF.setPromptText("%");
        forumTalkLabTF.setId("forumTalkLabTF");
        gridPane.add(forumTalkLab,1,17);
        gridPane.add(forumTalkLabTF,2,17);

        //作业成绩
        //标签
        Label taskScoreLab = new Label("作业成绩*");
        //文本框
        TextField taskScoreTF = new TextField();
        taskScoreTF.setId("taskScoreTF");
        taskScoreTF.setPromptText("%");
        gridPane.add(taskScoreLab,1,18);
        gridPane.add(taskScoreTF,2,18);

        //课程目标部分
        //标签
        Label courseAimLab = new Label("课程目标*");
        courseAimLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //文本域
        TextArea courseAimTA = new TextArea("为了更好的开展全国教师的培训.....");
        courseAimTA.setId("courseAimTA");
        gridPane.add(courseAimLab,0,19);
        gridPane.add(courseAimTA,1,19);

        //课程简介部分
        //标签
        Label courseIntroduceLab = new Label("课程简介*");
        courseIntroduceLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //文本域
        TextArea courseIntroduceTA = new TextArea("为了更好的开展全国教师的培训.....");
        courseIntroduceTA.setId("courseIntroduceTA");
        gridPane.add(courseIntroduceLab,0,20);
        gridPane.add(courseIntroduceTA,1,20);

        //最后修改人部分
        //标签
        Label endPersonLab = new Label("最后修改人");
        endPersonLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //人名标签
        TextField nameTF = new TextField("李某某");
        nameTF.setId("nameTF");
        gridPane.add(endPersonLab,0,21);
        gridPane.add(nameTF,1,21);

        //上次修改时间部分
        //标签
        Label lastTimeLab = new Label("上次修改时间");
        lastTimeLab.setFont(Font.font(null, FontWeight.BOLD,null,16));
        //时间文本框
        TextField timeTF = new TextField("2020-10-01 12：59");
        timeTF.setId("timeTF");
        gridPane.add(lastTimeLab,0,22);
        gridPane.add(timeTF,1,22);



        ObservableList<Node> children = tableHBox.getChildren();
        children.addAll(gridPane);






    }

    /**
     * 新增教学安排横向盒子
     * @param addTeacherArrangeHBox
     */
    private void initAddTeacherArrangeHBox(HBox addTeacherArrangeHBox) {
        addTeacherArrangeHBox.setPadding(new Insets(2));
        //新增教学安排标签
        Label addTeachingArrangeLab = new Label("新增教学安排");
        //设置字体大小
        addTeachingArrangeLab.setFont(Font.font(null, FontWeight.BOLD,null,22));
        addTeachingArrangeLab.setTextFill(Color.rgb(198,0,1));//字体颜色
        addTeacherArrangeHBox.getChildren().addAll(addTeachingArrangeLab);
    }

    /**
     * 顶部盒子
     * @param topHBox
     */
    private void initTopHBox(HBox topHBox) {
        topHBox.setSpacing(20);
        topHBox.setPadding(new Insets(2));
        //顶部标签
        Label topLab = new Label("当前位置：🏠>教学管理>教学安排>新增教学安排");
        topLab.setFont(new Font(20));//设置字体大小
        ObservableList<Node> children = topHBox.getChildren();
        children.addAll(topLab);
    }
}
